<?php

namespace Api\Controller;

use Common\Logic\RefundLogic;
use Common\Logic\GroupbuyLogic;

// header("content-type:application/json");
class TestController extends \Think\Controller
{
    // 导入遗失的身份证照片
    public function import()
    {
        $file = THINK_PATH.'../Public/sfz.txt';
        $data = file_get_contents($file);
        $data = explode("\n",$data);
        // var_dump($file,$data);
        foreach($data as $v)
        {
            $lineData = explode(" ",$v);
            // var_dump($lineData); 
            $saveData = [
                'szheng' => $lineData[1],
                'zheng' => $lineData[2],
            ];
            if( isset($lineData[3]) && !empty($lineData[3]) )
            {
                $saveData['fan'] = $lineData[3];
            }
            $update[$lineData[0]] = M('sm')->where([
                'sm_id' => $lineData[0]
            ])->save($saveData);
        }

        echo json_encode($update);

        // UPDATE `ln_sm` SET `szheng`='https://static.kgglcp.com/upload/2018-11-19/5bf20e8c6e8d2.jpg\r\nhttps://static.kgglcp.com/upload/2018-11-19/5bf20e8c6e8d2.jpg\r\nhttps://static.kgglcp.com/upload/2018-11-19/5bf20e8c6e8d2.jpg\r\nhttps://static.kgglcp.com/upload/2018-11-19/5bf20e8c6e8d2.jpg\r\n1' WHERE (`sm_id`='268')
    }
}